--编写者：alt
--功能介绍：增加科技树
--使用方法：直接粘贴到模组环境 修改techlist的内容 TECH[TECH_ID]的就是对应的科技

-- 代码作者：ti_Tout
local techlist = {
    TECH_NAME = {
        TECH_ID = "BAIZEALER_MACHINE",                                       --科技的id
        prototypeprefab = "baizealer_researchlab",                           --玩家靠近时会解锁科技的prefab名 例如一本
        icon_atlas = "images/inventoryimages/baizealer_researchlab_big.xml", --图标 注意：需要自己加载asset
        icon_image = "baizealer_researchlab_big.tex",
        action_str = "BAIZEALER_RESEARCH",
        filter_text = "格源星造站",
        OPEN_CRAFTING = "研究",
        needmachine = "寻找格源星造站制作原型！",
    },
}
for k, v in pairs(techlist) do
    local TECH_ID = v.TECH_ID
    local TechTree = require("techtree")
    local _G = GLOBAL
    table.insert(TechTree.AVAILABLE_TECH, TECH_ID)
    local Create_old = TechTree.Create
    TechTree.Create = function(t, ...)
        local newt = Create_old(t, ...)
        newt[TECH_ID] = newt[TECH_ID] or 0
        return newt
    end

    STRINGS.ACTIONS.OPEN_CRAFTING[TECH_ID] = v.OPEN_CRAFTING
    STRINGS.UI.CRAFTING_STATION_FILTERS[TECH_ID] = v.filter_text
    STRINGS.UI.CRAFTING["NEEDS" .. (TECH_ID)] = v.needmachine

    AddPrototyperDef(v.prototypeprefab, { --第一个参数是指玩家靠近时会解锁科技的prefab名
        icon_atlas = v.icon_atlas,
        icon_image = v.icon_image,

        action_str = TECH_ID,
        filter_text = STRINGS.UI.CRAFTING_STATION_FILTERS[TECH_ID]
    }
    )

    _G.TECH.NONE[TECH_ID] = 0
    _G.TECH[TECH_ID] = { [TECH_ID] = 1 }
    for _, vv in pairs(TUNING.PROTOTYPER_TREES) do
        vv[TECH_ID] = 0
    end
    TUNING.PROTOTYPER_TREES[TECH_ID] = TechTree.Create({ [TECH_ID] = 1 })
    for _, vv in pairs(AllRecipes) do
        if vv.level[TECH_ID] == nil then
            vv.level[TECH_ID] = 0
        end
    end
end
